<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>会员登录</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <form method="post" action="{:url('doLogin')}">
            <input type="text" name="username" placeholder="用户名" required="required" /><br />
            <input type="password" name="password" placeholder="密码" required="required" /><br />
            <button type="submit">登录</button>
            还没有帐号？<a href="{:url('registion/index')}">注册</a>
            {:token()}
        </form>
        <script type="text/javascript" src="/public/static/js/jquery-3.2.1.min.js"></script>
        <script>
            $('form').submit(function(){
                var $form=$(this);
                var data=$form.serialize();
                $.post($form.attr('action'),$form.serialize(),function(data){
                    if(typeof(data)!='object'){
                        alert(data);
                        return;
                    }
                    if(data.success){
                        location.href=data.url;
                    }else{
                        alert(data.message);
                    }
                })
                return false;
            })
        </script>
    </body>
</html>
